package com.cloud.note.model;

import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "attachments")
public class Attachment {

    @Id
    @Column(name = "id")
    private String id;

    @Column(name = "note_id", nullable = false)
    private String noteId;

    @Column(name = "name", nullable = false)
    private String name;

    @Column(name = "type", nullable = false)
    private String type;

    @Column(name = "uri", nullable = false)
    private String uri;

    @Column(name = "size", nullable = false)
    private Long size;

    @Column(name = "is_synced")
    private boolean isSynced;

    @CreationTimestamp
    @Column(name = "created_at", updatable = false)
    private LocalDateTime createdAt;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "note_id", referencedColumnName = "id", insertable = false, updatable = false)
    private Note note;
}